package com.zkt.subject.infra.rpc;

import com.zkt.auth.api.UserFeignService;
import com.zkt.auth.entity.AuthUserDTO;
import com.zkt.auth.common.entity.Result;
import com.zkt.subject.infra.entity.UserInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * @author 赵开泰
 * @program jc-club
 * @date 2025/3/23
 * @description 用户服务调用
 **/

@Component
public class UserRPC {
	
	@Resource
	private UserFeignService userFeignService;
	
	public UserInfo getUserInfo(String username) {
		Result<AuthUserDTO> result = userFeignService.getUserInfo(username);
		UserInfo userInfo = new UserInfo();
		if (!result.getSuccess()) {
			return userInfo;
		}
		AuthUserDTO data = result.getData();
		userInfo.setId(data.getId());
		userInfo.setUsername(data.getUserName());
		return userInfo;
	}
	
}